import 'package:fish_redux/fish_redux.dart';

import 'action.dart';
import 'state.dart';

Reducer<IndexPageState> buildReducer() {
  return asReducer(
    <Object, Reducer<IndexPageState>>{
      IndexPageAction.init: _init,
    },
  );
}

IndexPageState _init(IndexPageState state, Action action) {
  final IndexPageState newState = state.clone();
  final IndexPageState payload = action.payload ?? IndexPageState();

  newState.activeIndex = payload.activeIndex;
  newState.pages = payload.pages;

  return newState;
}
